/**
 * 表单数据模型
 */
module.exports = (app) => {
  const { INTEGER, STRING } = app.Sequelize
  const Parameter = app.model.define(
    'parameter',
    {
      id: {
        type: INTEGER,
        primaryKey: true,
        autoIncrement: true,
      },
      code: STRING(25),
      name: STRING(50),
    },
    {
      timestamps: false,
    }
  )

  Parameter.associate = function () {
    app.model.Parameter.belongsToMany(app.model.DataSource, {
      through: app.model.DataSourceParameter,
      foreignKey: 'parameterId',
      otherKey: 'dataSourceId',
    })
  }


  return Parameter
}
